﻿using EventBusETO.RoomType;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SH.Common.CommonReturn;
using SH.Order.Application.IServices.Dto;
using SH.Order.Application.IServices.IClientcu;
using SH.Order.Domain.OrderClass;
using Snowflake.Core;
using SqlSugar.DistributedSystem.Snowflake;
using SqlSugar.Extensions;
using System.Net.Http;


namespace SH.Order.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ClientcuStomerController : ControllerBase
    {
        private readonly IClientcuServices _clientcuServices;

        public ClientcuStomerController(IClientcuServices clientcuServices)
        {
            _clientcuServices = clientcuServices;
        }
        /// <summary>
        /// 获取雪花id
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult SnowIdWithTimestamp()
        {
            long timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); // 获取当前时间的 Unix 时间戳
            string snowflakeId = new Snowflake.Core.IdWorker(1, 1).NextId().ToString();

            string snowIdWithTimestamp = $"{timestamp}";
            return Ok(snowIdWithTimestamp);
        }
        /// <summary>
        /// 办理入住
        /// </summary>
        /// <param name="clientcuStomerdto"></param>
        /// <returns></returns>
        [HttpPost]
        public   async Task<IActionResult>  AddClientcu(ClientcuStomerDto clientcuStomerdto)
        {
            var result =  await _clientcuServices.AddClientcu(clientcuStomerdto);
            return  Ok(result);
          
        }
        /// <summary>
        /// 显示房型和房间列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public IActionResult  RoomShow()
        {
            return Ok(_clientcuServices.RoomShow());
        }
        /// <summary>
        /// 房号显示
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public IActionResult RoomNumShow(int id)
        {
            return Ok(_clientcuServices.RoomNumShow(id));
          
        }
        [HttpGet]
        public IActionResult clientcuShow()
        {
            return Ok(_clientcuServices.clientcuShow());
        }
        /// <summary>
        /// 住宿订单显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult ClientcuStomersShow(DateTime? StartTime, DateTime? EndTime, int pageIndex, int pageSize, int StateId = -1)
        {

            return Ok(_clientcuServices.ClientcuStomersShow(StartTime, EndTime, pageIndex: pageIndex, pageSize, StateId));
        }
        /// <summary>
        /// 订单详情
        /// </summary>
        [HttpGet]
        public IActionResult ClientcuStomersFind(int id)
        {
            return Ok(_clientcuServices.ClientcuStomersFind(id));
        }

    }
}
